import pandas as pd
import numpy as np
from sqlalchemy import create_engine


def write_sql():
    frame = pd.DataFrame(np.arange(20).reshape(4,5),
                         columns=['white', 'red', 'blue', 'black', 'green'])
    engine= create_engine('sqlite:///D:\\learn_and_test_data\\foo.db')
    print(frame)
    frame.to_sql('colors', engine, if_exists="append", index=False)


def read_sql():
    engine = create_engine('sqlite:///D:\\learn_and_test_data\\foo.db')
    frame = pd.read_sql('colors', engine)
    print(frame)


if __name__ == '__main__':
    write_sql()
    read_sql()
